package com.wn32.main.demo7;

import sun.awt.windows.ThemeReader;
//synchronized(this)锁的是对象,多个对象this不唯一,不能保证线程安全
public class Main9 {
    public static void main(String[] args) {
        Shop shop1 = new Shop();
        Shop shop2 = new Shop();

        Thread th1=new Thread(()->{
            shop1.buyOne();
        },"线程A");

        Thread th2=new Thread(()->{
            shop2.buyOne();
        },"线程B");

        th1.start();
        th2.start();
    }
}
